/**
 * 单词本相关 API
 * @author 杨世峰
 */

import request from '@/utils/request'

export function getUserBooklets(userId, params) {
    return request({
        method: 'get',
        url: '/booklets/' + userId,
        params: params
    })
}

export function getWord(wordSpell) {
    return request({
        method: 'get',
        url: '/words/' + wordSpell
    })
}

export function getBookletDetail(bookletId) {
    return request({
        method: 'get',
        url: '/booklets/booklet/' + bookletId
    })
}

export function getBookletEntries(bookletId, params) {
    return request({
        method: 'get',
        url: '/booklets/'+ bookletId +'/' + 'entries',
        params: params
    })
}

export function createBooklet(data) {
    return request({
        method: 'post',
        url: '/booklets',
        data: data
    })
}

export function deleteBooklet(bookletId) {
    return request({
        method: 'delete',
        url: '/booklets/' + bookletId
    })
}

export function addEntryToBooklet(bookletId, data) {
    return request({
        method: 'post',
        url: '/booklets/' + bookletId + '/entries',
        data: data
    })
}

export function learnWords(bookletId, data) {
    return request({
        method: 'put',
        url: '/booklets/' + bookletId + '/entries',
        data: data
    })
}

export function getLearningWords(bookletId) {
    return request({
        method: 'get',
        url: '/booklets/words/' + bookletId
    })
}